#pragma once

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

#ifndef NDEBUG
	#define DOUT( toprint ) printf( "\n# " toprint )        //!< Debug output, prints a plain text line preceded by #
	#define DPUT( toput , x ) printf( "\n# " toput , x )	//!< Debug put, a DOUT with a single variable inside
	#define DLN                                             //!< Debug line, doesn't exist in release ( with NDEBUG defined )
	#define DPUTCLOSURE	DOUT("=============================================================================");\
		DPUT("FILE: %s", __FILE__); \
		DPUT("COMPILATION DATE: %s", __DATE__); \
		DPUT("COMPILATION TIME: %s\n", __TIME__)//!< Put a closing statement, complete with datestamp and finename.
#else
	#define DOUT
	#define DPUT
	#define DLN if(0)
	#define DPUTCLOSURE
#endif

//////////////////////////////////////////////////////////////////////////
typedef long tree_data;

typedef struct tree_node {
	tree_node *parent;
	tree_node *left;
	tree_node *right;
	tree_data data;
} tree_node;
//////////////////////////////////////////////////////////////////////////

tree_node* tnode_construct(tree_node*);

int tnode_add_mt(tree_node*);
int tnode_add(tree_node*, tree_data);

void tree_destruct(tree_node*);

void tree_print(tree_node*, FILE*);
tree_node* tree_scan(FILE*);


